package de.sonnentempel.view;

import java.awt.EventQueue;

import javax.swing.JDialog;
import javax.swing.JFrame;

import org.jdesktop.swingx.JXTable;

import java.awt.BorderLayout;
import java.awt.GridLayout;

import org.jdesktop.swingx.JXTextField;
import org.jdesktop.swingx.JXLabel;

import net.miginfocom.swing.MigLayout;

import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class MainView {

	private JFrame frame;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainView window = new MainView();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public MainView() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 844, 655);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(
				new MigLayout("", "[][grow]", "[][][][][][grow][]"));

		JXLabel lblAsljfhkajsghkajsghakjsgh = new JXLabel();
		lblAsljfhkajsghkajsghakjsgh.setText("Suche");
		frame.getContentPane().add(lblAsljfhkajsghkajsghakjsgh,
				"cell 0 0,alignx trailing");

		JXTextField textField = new JXTextField();
		frame.getContentPane().add(textField, "cell 1 0,growx");

		JXTable table = new JXTable();
		frame.getContentPane().add(table, "cell 0 5 2 1,grow");
		

		JButton btnBesuchHinzufgen = new JButton("Besuch hinzuf\u00FCgen");
		btnBesuchHinzufgen.addActionListener(new ActionListener() {
			private BesuchView besuchView;

			public void actionPerformed(ActionEvent arg0) {
				if (besuchView == null) {
					besuchView = new BesuchView();
					besuchView.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
					
				} else {
					
					besuchView.requestFocus();
				}
				besuchView.setVisible(true);
			}
		});
		frame.getContentPane().add(btnBesuchHinzufgen, "flowx,cell 1 6");

		JButton btnKundeHinzufgen = new JButton("Kunde hinzuf\u00FCgen");
		frame.getContentPane().add(btnKundeHinzufgen, "cell 1 6");

		JButton btnKundeBearbeiten = new JButton("Kunde bearbeiten");
		frame.getContentPane().add(btnKundeBearbeiten, "cell 1 6");

		JButton btnKundeLschen = new JButton("Kunde l\u00F6schen");
		frame.getContentPane().add(btnKundeLschen, "cell 1 6");
	}
}
